package com.huazai.out_school_manager.Servlet;

import com.huazai.out_school_manager.Dao.UserDao;
import com.huazai.out_school_manager.Dao.realization.UserDaoReal;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet(name = "delete",value = "/delete")
public class DeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserDao userDao = new UserDaoReal();
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter pw = response.getWriter();

        String applyID = request.getParameter("applyID");

        /**
         * 需要再去学习怎么把数据传到后端，继续跟老杜学一学
         * 解答：来在地址栏上解决
         */
        if ( userDao.deleteSubmit(applyID) ) {
            pw.print("<h1 align='center'>出校申请删除成功</h1>");
        }
        else {
            pw.print("<h1 align='center'>出校申请删除失败</h1>");
        }
        pw.print("<a href='javascript:void(0)' onclick='window.history.back()'>返回上一级</a>");
    }
}
